/*
 * PostalAddress.java
 */
package model;

/**
 * PostalAddress represents a US address with street, city, state, and zip code.
 * 
 * @author Doug Hutchens
 * @author Carlo Consolacion
 * @authoer Sean Brown
 * @author 2.0
 */
public class PostalAddress implements Cloneable {

	/**
	 * The street for this address.
	 */
	private String my_street;

	/**
	 * The city of this address.
	 */
	private String my_city;

	/**
	 * The state of this address.
	 */
	private String my_state;

	/**
	 * The zip code for this address.
	 */
	private String my_postal_code;

	/**
	 * The make up of a postal address
	 * 
	 * @param the_street
	 *            , the street name in string
	 * @param the_city
	 *            , the city name in string
	 * @param the_state
	 *            , the state name abbreviated in string
	 * @param the_postalCode
	 *            , the postal code in string
	 */
	public PostalAddress(String the_street, String the_city, String the_state,
			String the_postal_code) {
		my_street = the_street;
		my_city = the_city;
		my_state = the_state;
		my_postal_code = the_postal_code;
	}

	/**
	 * This method will allow program to get the street name in string
	 * 
	 * @return a string representation of the street
	 */
	public String getStreet() {
		return my_street;
	}

	/**
	 * This method will allow program to get the city name in string
	 * 
	 * @return a string representation of the city
	 */
	public String getCity() {
		return my_city;
	}

	/**
	 * This method will allow program to get the state name(abbreviation) in
	 * string
	 * 
	 * @return a string representation of the state
	 */
	public String getState() {
		return my_state;
	}

	/**
	 * This method will allow program to get the postal code in string.
	 * 
	 * @return a string representation of the postal code.
	 */

	public String getPostalCode() {
		return my_postal_code;
	}

	/**
	 * This method is returns the string representation of the PostalAddress.
	 * 
	 * @return String representation of PostalAddress.
	 */
	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		final String new_line = "\n";
		sb.append(my_street);
		sb.append(new_line);
		sb.append(my_city);
		sb.append(", ");
		sb.append(my_state);
		sb.append(" ");
		sb.append(my_postal_code);
		return sb.toString();
	}

	/**
	 * This method returns a clone of the PostalAddress.
	 */
	@Override
	public Object clone() {
		return new PostalAddress(my_street, my_city, my_state, my_postal_code);
	}

	/**
	 * This method overrides the equals method.
	 */
	@Override
	public boolean equals(final Object obj) {
		boolean equal = false;
		if (obj != null && getClass() == obj.getClass()) {
			equal = ((PostalAddress) obj).hashCode() == hashCode();
		}
		return equal;
	}

	/**
	 * This method overrides the hashCode method.
	 */
	@Override
	public int hashCode() {
		return my_street.hashCode() + my_city.hashCode() + my_state.hashCode()
				+ my_postal_code.hashCode();
	}

}
